using QFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ExpUpgradeItem
{
    public ExpUpgradeItem(bool isWeapon)
    {
        this.isWeapon = isWeapon;
    }
    public string Name { get; private set; }
        
    public bool isWeapon = false;
    public bool UpgradeFinish { get; set; } = false;
    public string Key { get; private set; }
    public string Description => mDescription(CurrentLevel.Value+1);
    public string IconName { get; private set; }
    public string PairedName { get; private set; }
    public string PairedIconName { get; private set; }
    public string PairedDescription { get; private set; }
    public int MaxLevel { get; private set; } = 10;
    public BindableProperty<int> CurrentLevel =new BindableProperty<int>(0);
    public BindableProperty<bool> Visible = new BindableProperty<bool>();
    public Func<ExpUpgradeItem, bool> mCondition;
    private Func<int, string> mDescription;
    public void UpGrade()
    {
        CurrentLevel.Value++;
        if (CurrentLevel.Value > MaxLevel)
        {
            UpgradeFinish = true;
        }
        mOnUpgrade?.Invoke(this, CurrentLevel.Value);



    }

    private Action<ExpUpgradeItem, int> mOnUpgrade;

    public ExpUpgradeItem WithKey(string key)
    {
        Key = key;
        return this;
    }
    public ExpUpgradeItem WithName(string name)
    {
        Name = name;
        return this;
    }
    public ExpUpgradeItem WithIconName(string iconname)
    {
        IconName = iconname;
        return this;
    }


    public ExpUpgradeItem WithPairedName(string pairedName)
    {
        PairedName = pairedName;
        return this;
    }
    public ExpUpgradeItem WithPairedIconName(string pairedIconName)
    {
        PairedIconName = pairedIconName;
        return this;
    }
    public ExpUpgradeItem WithPairedDescription(string pairedDescription)
    {
        PairedDescription = pairedDescription;
        return this;
    }
    public ExpUpgradeItem WithDescription(Func<int, string> mDescription)
    {
        this.mDescription = mDescription;
        return this;
    }
    public ExpUpgradeItem OnUpgrade(Action<ExpUpgradeItem, int> onUpgrade)
    {
        mOnUpgrade = onUpgrade;
        return this;
    }

    public ExpUpgradeItem Condition(Func<ExpUpgradeItem, bool> func)
    {
        mCondition = func;
        return this;
    }

    public ExpUpgradeItem WithMaxLevel(int maxlevel)
    {
        MaxLevel = maxlevel;
        return this;
    }
}
